﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.Script.Serialization;
using HMS.Security;
using System.Threading;
using System.Text;

public partial class _demo_Welcome : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        JavaScriptSerializer js = new JavaScriptSerializer();
        String scriptText = "";

        HMSPrincipal principal;
        principal = (HMSPrincipal)Thread.CurrentPrincipal;
        HMSIdentity userIdentity = principal.identity;
        Int32 userid = userIdentity.userPK;
        StringBuilder jsonBuilder = new StringBuilder();
        jsonBuilder.Append("{");
        jsonBuilder.Append("\"IS_DASHBOARD_ALLOWED\":" + userIdentity.IsDashboard.ToString().ToLower());
        jsonBuilder.Append(",\"IS_DIMESIONS_ALLOWED\":" + userIdentity.IsDimesion.ToString().ToLower());
        jsonBuilder.Append(",\"IS_GROUPING_ALLOWED\":" + userIdentity.IsGrouping.ToString().ToLower());
        jsonBuilder.Append(",\"IS_REPORT_ALLOWED\":" + userIdentity.IsReport.ToString().ToLower());
        jsonBuilder.Append(",\"IS_CONFIG_ALLOWED\":" + userIdentity.IsConfig.ToString().ToLower());
        jsonBuilder.Append("}");

        //HMS.Security.HMSPrincipal HMSPrincipal = (HMS.Security.HMSPrincipal)HttpContext.Current.User;
        scriptText = "<script language='javascript'>";
        //original code
        // scriptText += "document.body.onload=function(){ DisableTab('" + js.Serialize(Session["IsTabAllowed"]) + "')};";
        scriptText += "document.body.onload=function(){ DisableTab('" + jsonBuilder.ToString() + "')};";

        scriptText += "</script>";
        ClientScript.RegisterClientScriptBlock(this.GetType(), "Pop", scriptText);
        //}
    }

}
